import { Navigate, Outlet } from "react-router-dom"
import { useAppSelector } from "@/app/hooks"
import { selectUser } from "@/app/user/userSlice"
import { Routes } from "@/shared/consts"
import { getToken } from "@/app/auth/authHeader"

const AuthLayout = () => {
  const token = getToken()
  const user = useAppSelector(selectUser)
  if (user || token) {
    return <Navigate to={Routes.Profile} replace />
  }
  return <Outlet />
}
export default AuthLayout
